//app.js
App({
  onLaunch: function () {
    wx.clearStorageSync('goods');
    var goods = wx.getStorageSync('goods');
    if(!goods){
        goods = this.loadGoods();
    }
    wx.setStorageSync('goods', goods);
  },
   loadGoods:function(){
    
    var goods = new Array();
    var good = new Object();

    good.id="1000";//商品唯一标识
    good.pic = '/images/pic/miphone.jpg'; //商品图片
     good.name ='肌肉猪公仔搞怪小玩偶儿童毛绒玩具沙发靠枕小猪布娃娃男生礼物';//商品名称
    good.nowPrice='79.00';//商品现价
    good.oldPrice = '999.00';//商品原价
    good.soldCount = '963';//商品售出数量
    good.coupon = ['满50减20','满100减50'];//商品优惠券
    good.promotion = ['限购', '限制','满减'];//商品促销
    good.color = ['生气款', '墨镜款', '马甲款'];//商品颜色
    good.count = 1;//商品数量
    good.address='四川省 眉山市 仁寿县区 15609';//商家地址
    good.promise = ['免运费', '哒哒哒发货&售后', '七天退货', '24限时达', '货到付款'];//商家承诺
    good.desc = '10:00之前下单，预计第二天送达';//商品说明
    good.photos = ['/images/haibao/miphone/m1.png', '/images/haibao/miphone/m2.png', '/images/haibao/miphone/m3.png', '/images/haibao/miphone/m4.png'];//商品组图
    good.isjd = "1";//是否是哒哒哒自营，1代表自营，0代表不是自营
    goods[0] = good;

    var good1 = new Object();
    good1.id = "1001";//商品唯一标识
    good1.pic = '/images/pic/shoes.jpg'; //商品图片
     good1.name = '蜡笔小新葫芦小新 超大号葫芦文玩潮玩家居摆件手办蜡笔小新手办';//商品名称
    good1.nowPrice = '99.00';//商品现价
    good1.oldPrice = '899.00';//商品原价
    good1.soldCount = '72';//商品售出数量
    good1.coupon = ['满199减40', '满300减100'];//商品优惠券
    good1.promotion = ['限购', '限制', '满减'];//商品促销
    good1.color = ['无挂件', '有挂件'];//商品颜色
    good1.size = ['小号', '大号', ];//商家尺寸
    good1.count = 1;//商品数量
    good1.address = '四川省 眉山市 钢铁镇 15609';//商家地址
    good1.promise = ['商家发货&售后', '七天退货', '货到付款', '运费险'];//商家承诺
    good1.desc = '免运费';//商品说明
    good1.photos = ['/images/haibao/shoes/1.jpg', '/images/haibao/shoes/2.jpg', '/images/haibao/shoes/3.jpg', '/images/haibao/shoes/4.jpg', '/images/haibao/shoes/5.jpg'];//商品组图
    good1.isjd = "1";//是否是哒哒哒自营，1代表自营，0代表不是自营
    goods[1] = good1;

    var good2 = new Object();
    good2.id = "1002";//商品唯一标识
    good2.pic = '/images/pic/cup.jpg'; //商品图片
     good2.name = '兼容乐高积木1:手工音乐盒大提琴木质拼装模型3d立体拼图diy成人益智玩具好礼物';//商品名称
    good2.nowPrice = '49.90';//商品现价
    good2.oldPrice = '109.00';//商品原价
    good2.soldCount = '15';//商品售出数量
    good2.coupon = ['满299减20', '满499减50'];//商品优惠券
    good2.promotion = ['限购', '限制'];//商品促销
    good2.color = ['礼盒版', '豪华版', '普通版'];//商品颜色
    good2.count = 1;//商品数量
    good2.address = '四川省 眉山市 钢铁镇 15609';//商家地址
    good2.promise = ['商家发货&售后', '七天退货', '货到付款'];//商家承诺
    good2.desc = '店铺单笔订单不满59元，收运费10元';//商品说明
    good2.photos = ['/images/haibao/cup/1.jpg', '/images/haibao/cup/2.jpg', '/images/haibao/cup/3.jpg', '/images/haibao/cup/4.jpg', '/images/haibao/cup/5.jpg'];//商品组图
    good2.isjd = "0";//是否是自营，1代表自营，0代表不是自营
    goods[2] = good2;

    var good3 = new Object();
    good3.id = "1003";//商品唯一标识
    good3.pic = '/images/pic/purifier.jpg'; //商品图片
    good3.name = '兼容乐高积木1:14兰博基尼遥控超跑赛车儿童益智力拼装玩具男孩子';//商品名称
    good3.nowPrice = '2849.00';//商品现价
    good3.oldPrice = '2899.00';//商品原价
    good3.soldCount = '23';//商品售出数量
    good3.promotion = ['加价购', '限购', '限制'];//商品促销
    good3.count = 1;//商品数量
    good3.address = '四川省 眉山市 钢铁镇 15609';//商家地址
    good3.promise = ['99元免基础运费(20kg内)', '哒哒哒发货&售后', '七天退货', '24限时达', '货到付款'];//商家承诺
    good3.desc = '10：00前下单，预计第二天送达';//商品说明
    good3.photos = ['/images/haibao/purifier/1.jpg', '/images/haibao/purifier/2.jpg', '/images/haibao/purifier/3.jpg', '/images/haibao/purifier/4.jpg', '/images/haibao/purifier/5.jpg'];//商品组图
    good3.isjd = "1";//是否是哒哒哒自营，1代表自营，0代表不是自营
    goods[3] = good3;

    var good4 = new Object();
    good4.id = "1004";//商品唯一标识
    good4.pic = '/images/pic/haier.jpg'; //商品图片
    good4.name = '正版原创鸡蛋柴柴沙雕柴犬狗蛋模玩潮玩gk手办公仔桌面车内摆件';//商品名称
    good4.nowPrice = '38.00';//商品现价
    good4.oldPrice = '49.00';//商品原价
    good4.soldCount = '322';//商品售出数量
    good4.promotion = ['加价购', '限购', '限制', '优惠套装'];//商品促销
    good4.count = 1;//商品数量
    good4.color = ['挂件', '手办'];//商品颜色
    good4.address = '四川省 眉山市 钢铁镇 15609';//商家地址
    good4.promise = ['免运费', '哒哒哒发货&售后', '七天退货', '货到付款'];//商家承诺
    good4.desc = '18：00前下单，预计第二天送达';//商品说明
    good4.photos = ['/images/haibao/haier/1.jpg', '/images/haibao/haier/2.jpg', '/images/haibao/haier/3.jpg', '/images/haibao/haier/4.jpg', '/images/haibao/haier/5.jpg'];//商品组图
    good4.isjd = "1";//是否是哒哒哒自营，1代表自营，0代表不是自营
    goods[4] = good4;

    return goods;

  },
  getUserInfo:function(cb){
    var that = this
    if(this.globalData.userInfo){
      typeof cb == "function" && cb(this.globalData.userInfo)
    }else{
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  globalData:{
    userInfo:null
  }
})